home *** CD-ROM | disk | FTP | other *** search
/ PC Plus SuperCD (UK) 1997 May / PC Plus Super CD Issue 127 (May 1997).iso / handson / java / classes / aboutdialog.class (.txt) next >
Encoding:
Java Class File  |  1997-02-07  |  2.2 KB  |  58 lines

  1. import java.awt.Button;
  2. import java.awt.Component;
  3. import java.awt.Container;
  4. import java.awt.Dialog;
  5. import java.awt.Event;
  6. import java.awt.Frame;
  7. import java.awt.Label;
  8. import java.awt.LayoutManager;
  9. import java.awt.Rectangle;
  10.  
  11. public class AboutDialog extends Dialog {
  12.    Label label1;
  13.    Button doneButton;
  14.  
  15.    void doneButton_Clicked(Event event) {
  16.       ((Component)this).hide();
  17.    }
  18.  
  19.    public AboutDialog(Frame parent, boolean modal) {
  20.       super(parent, modal);
  21.       ((Container)this).setLayout((LayoutManager)null);
  22.       ((Dialog)this).addNotify();
  23.       ((Component)this).resize(((Container)this).insets().left + ((Container)this).insets().right + 327, ((Container)this).insets().top + ((Container)this).insets().bottom + 91);
  24.       this.label1 = new Label("A basic Java application");
  25.       this.label1.reshape(((Container)this).insets().left + 26, ((Container)this).insets().top + 33, 181, 19);
  26.       ((Container)this).add(this.label1);
  27.       this.doneButton = new Button("Done");
  28.       this.doneButton.reshape(((Container)this).insets().left + 233, ((Container)this).insets().top + 16, 60, 40);
  29.       ((Container)this).add(this.doneButton);
  30.       ((Dialog)this).setResizable(false);
  31.    }
  32.  
  33.    public AboutDialog(Frame parent, String title, boolean modal) {
  34.       this(parent, modal);
  35.       ((Dialog)this).setTitle(title);
  36.    }
  37.  
  38.    public synchronized void show() {
  39.       Rectangle bounds = ((Component)this).getParent().bounds();
  40.       Rectangle abounds = ((Component)this).bounds();
  41.       ((Component)this).move(bounds.x + (bounds.width - abounds.width) / 2, bounds.y + (bounds.height - abounds.height) / 2);
  42.       super.show();
  43.    }
  44.  
  45.    public boolean handleEvent(Event event) {
  46.       if (event.id == 201) {
  47.          ((Component)this).hide();
  48.          return true;
  49.       } else {
  50.          if (event.target == this.doneButton && event.id == 1001) {
  51.             this.doneButton_Clicked(event);
  52.          }
  53.  
  54.          return super.handleEvent(event);
  55.       }
  56.    }
  57. }
  58.